Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
validator.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017 Roc authors
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 */
8
9//! @file roc_rtp/validator.h
10//! @brief RTP validator.
11
12#ifndef ROC_RTP_VALIDATOR_H_
13#define ROC_RTP_VALIDATOR_H_
14
16#include "roc_core/time.h"
17#include "roc_packet/ireader.h"
18
19namespace roc {
20namespace rtp {
21
22//! Validator parameters.
24 //! Maximum allowed delta between two consecutive packet seqnums.
26
27 //! Maximum allowed delta between two consecutive packet timestamps, in nanoseconds.
29
31 : max_sn_jump(100)
32 , max_ts_jump(core::Second) {
33 }
34};
35
36//! RTP validator.
38public:
39 //! Initialize.
40 //!
41 //! @b Parameters
42 //! - @p reader is input packet reader
43 //! - @p config defines validator parameters
44 //! - @p sample_rate defines session sample rate
45 Validator(packet::IReader& reader, const ValidatorConfig& config, size_t sample_rate);
46
47 //! Read next packet.
48 //! @remarks
49 //! Reads packet from the underlying reader and validates it. If the packet
50 //! is valid, return it. Otherwise, returns NULL.
52
53private:
54 bool check_(const packet::RTP& prev, const packet::RTP& next) const;
55
56 packet::IReader& reader_;
57 packet::PacketPtr prev_packet_;
58
59 const ValidatorConfig config_;
60 const size_t sample_rate_;
61};
62
63} // namespace rtp
64} // namespace roc
65
66#endif // ROC_RTP_VALIDATOR_H_
Base class for non-copyable objects.
Definition: noncopyable.h:23
Packet reader interface.
Definition: ireader.h:21
RTP validator.
Definition: validator.h:37
virtual packet::PacketPtr read()
Read next packet.
Validator(packet::IReader &reader, const ValidatorConfig &config, size_t sample_rate)
Initialize.
int64_t nanoseconds_t
Nanoseconds.
Definition: time.h:21
Root namespace.
Non-copyable object.
Packet reader interface.
RTP packet.
Definition: rtp.h:23
Validator parameters.
Definition: validator.h:23
core::nanoseconds_t max_ts_jump
Maximum allowed delta between two consecutive packet timestamps, in nanoseconds.
Definition: validator.h:28
size_t max_sn_jump
Maximum allowed delta between two consecutive packet seqnums.
Definition: validator.h:25
Time definitions.